#include<bits/stdc++.h>
using namespace std;
map<long long,string>s;
map<string,long long>s1;
int main()
{
	int n;
	cin>>n;
	while(n--){
		char x;
		string y;
		long long num;
		cin>>x>>num>>y;
		//getchar();
		if(x=='L'){
			//if(num<1000||num>1000000000||y.size()>16||y.size()<6){cout<<"ERROR: Wrong PW\n";}
			if(s.find(num)==s.end())
				{
				cout<<"ERROR: Not Exist\n";}
			else if(s[num]!=y)
				{cout<<"ERROR: Wrong PW\n";}
			else
				{cout<<"Login: OK\n";}
		}
		else if(x=='N'){
			if(s.find(num)!=s.end()){
				cout<<"ERROR: Exist\n";
			}		
			else //if(num>1000&&num<=1000000000&&y.size()<=16&&y.size()>=6);
			{
				s[num]=y;
				s1[y]=num;
				cout<<"New: OK\n";
			}
				
		}
	}
	return 0;
}
